import requests
from pyquery import PyQuery as pq
import json


url = 'https://news.southcn.com/node_179d29f1ce'
res = requests.get(url).text
lists = pq(res)

itms = lists('.itm.j-link').items()

collectedData = {
    'code':200,
    'data': []
}

for itm in itms:
    itemData = {
        'title': itm('a').attr('title'),
        'coverImgSrc': itm('.img').attr('src'),
        'time': itm('.time').text(),
        'articleUrl': itm('a').attr('href'),
    }
    collectedData['data'].append(itemData)

jsonData = json.dumps(collectedData,ensure_ascii =False,indent=2)
jsonFile = open('news.json', 'w',encoding='utf-8')
jsonFile.write(jsonData)
jsonFile.close()
